From d2f23500b0bd865763b51cbe2fd99db4d0adb0bf Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 7 Jun 2006 15:46:05 +0100 Subject: [PATCH] Extended PHYSDEVOP_irq_status_query to obtain sharing status (bound to multiple guests?). Signed-off-by: Keir Fraser --- xen/arch/x86/irq.c | 22 ++++++++++++++++++++++ xen/arch/x86/physdev.c | 9 ++++----- xen/include/asm-x86/irq.h | 3 +++ xen/include/public/physdev.h | 7 ++++++- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index d6d12841b6..b12c2f5ba0 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -402,6 +402,28 @@ int pirq_acktype(int irq) return 0; } +int pirq_shared(int irq) +{ + unsigned int vector; + irq_desc_t *desc; + irq_guest_action_t *action; + unsigned long flags; + int shared; + + vector = irq_to_vector(irq); + if ( vector == 0 ) + return 0; + + desc = &irq_desc[vector]; + + spin_lock_irqsave(&desc->lock, flags); + action = (irq_guest_action_t *)desc->action; + shared = ((desc->status & IRQ_GUEST) && (action->nr_guests > 1)); + spin_unlock_irqrestore(&desc->lock, flags); + + return shared; +} + int pirq_guest_bind(struct vcpu *v, int irq, int will_share) { unsigned int vector; diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c index 48d259c85d..caf6f393e4 100644 --- a/xen/arch/x86/physdev.c +++ b/xen/arch/x86/physdev.c @@ -12,15 +12,12 @@ #include #include -extern int +int ioapic_guest_read( unsigned long physbase, unsigned int reg, u32 *pval); -extern int +int ioapic_guest_write( unsigned long physbase, unsigned int reg, u32 pval); -extern int -pirq_acktype( - int irq); long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) { @@ -56,6 +53,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) irq_status_query.flags = 0; if ( pirq_acktype(irq) != 0 ) irq_status_query.flags |= XENIRQSTAT_needs_eoi; + if ( pirq_shared(irq) ) + irq_status_query.flags |= XENIRQSTAT_shared; ret = copy_to_guest(arg, &irq_status_query, 1) ? -EFAULT : 0; break; } diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h index 4d64e53344..33aff7150c 100644 --- a/xen/include/asm-x86/irq.h +++ b/xen/include/asm-x86/irq.h @@ -46,4 +46,7 @@ extern unsigned long io_apic_irqs; extern atomic_t irq_err_count; extern atomic_t irq_mis_count; +int pirq_acktype(int irq); +int pirq_shared(int irq); + #endif /* _ASM_HW_IRQ_H */ diff --git a/xen/include/public/physdev.h b/xen/include/public/physdev.h index 0fced1fdaf..7c53951b56 100644 --- a/xen/include/public/physdev.h +++ b/xen/include/public/physdev.h @@ -37,7 +37,11 @@ DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t); /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */ #define _XENIRQSTAT_needs_eoi (0) -#define XENIRQSTAT_needs_eoi (1<<_XENIRQSTAT_needs_eoi) +#define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi) + +/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */ +#define _XENIRQSTAT_shared (1) +#define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared) /* * Set the current VCPU's I/O privilege level. @@ -130,6 +134,7 @@ DEFINE_XEN_GUEST_HANDLE(physdev_op_t); #define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write #define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi +#define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared #endif /* __XEN_PUBLIC_PHYSDEV_H__ */ -- 2.30.2